﻿using AutoMapper;
using MediatR;
using SheepStorage.API.Application.Command.UserInfoCommand;
using SheepStorage.API.Baseclass;
using SheepStorage.Service.Interface;

namespace SheepStorage.API.Application.CommandHandlers.UserInfoHandlers
{
	public class UserInfoUpdateImageHandler : IRequestHandler<UserInfoUpdateStateCommand, Results<int>>
	{

		private readonly IUserInfoService userInfoService;
		private readonly IMapper mapper;

		public UserInfoUpdateImageHandler(IUserInfoService userInfoService, IMapper mapper)
		{
			this.userInfoService = userInfoService;
			this.mapper = mapper;
		}

		public async Task<Results<int>> Handle(UserInfoUpdateStateCommand request, CancellationToken cancellationToken)
		{
			//throw new NotImplementedException();

			var res = await userInfoService.UpdateUserHeadImage(request.UserId, request.HeadImage);
			return Results<int>.DataResult(res);
		}
	}
}
